import { sendRequest } from '@/http';

export interface LoginData {
  account: string;
  password: string;
}

export interface LoginRes {
  token: string;
}

export const login = (params: any) =>
  sendRequest({
    url: `/admin/account/loginWithPassword`,
    method: 'post',
    data: params,
  });

export const logout = () => {
  return new Promise((resolve) => {
    setTimeout(resolve, 500);
  });
};

export function getUserInfo() {
  return sendRequest({
    url: `/admin/staff/querySelfInfo`,
    method: 'get',
  });
}

export function getUserPermission() {
  return sendRequest({
    url: `/admin/staff/permissions`,
    method: 'get',
  });
}

export function getUserRoles() {
  return sendRequest({
    url: `/admin/staff/roles`,
    method: 'get',
  });
}

export function getMenuList() {
  return sendRequest({
    url: `/api/user/menu`,
    method: 'get',
  });
}
